/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import ejb.model.EJBModel;
import gui.popup.ContextMenuMouseListener;
import inputverifier.LengthVerifier;
import inputverifier.NumberVerifier;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import model.gui.MenuModel;
import model.supplier.CountryComboBoxModel;
import model.supplier.LanguageComboboxModel;
import model.supplier.TelecomTabelModel;
import model.supplier.TelecomtypeComboBoxModel;
import util.person.SupplierDetails;
import util.person.address.AddressDetails;

/**
 *
 * @author Gebruiker
 */
public class SupplierForm extends JPanel implements FocusListener {

    private TelecomTabelModel telecomTableModel;
    private CountryComboBoxModel countryComboBoxModel;
    private LanguageComboboxModel languageComboBoxModel;
    private boolean newSupplier;
    private SupplierDetails currentSupplier;
    private AddressDetails currentAddress;
    private MenuModel model;

    /**
     * Creates new form SupplierForm
     */
    public SupplierForm(MenuModel model) {
        newSupplier = true;
        countryComboBoxModel = new CountryComboBoxModel();
        languageComboBoxModel = new LanguageComboboxModel();
        telecomTableModel = new TelecomTabelModel();
        initComponents();
        number_Txt.addFocusListener(this);
        String[] items = {"1", "2", "3", "4", "5"};
        JComboBox combo = new JComboBox(new TelecomtypeComboBoxModel());
        telecom_tbl.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(combo));
        this.model = model;

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        jPopupMenu2 = new javax.swing.JPopupMenu();
        jLabel1 = new javax.swing.JLabel();
        number_Txt = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        name_txt = new javax.swing.JTextField();
        name_txt.addMouseListener(new ContextMenuMouseListener());
        jLabel3 = new javax.swing.JLabel();
        street_txt = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        streetNumber_txt = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        bus_txt = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        country_cmb = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        postalCode_txt = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        location_txt = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        language_cmb = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        telecom_tbl = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel10 = new javax.swing.JLabel();
        save_btn = new javax.swing.JButton();
        addTelecom = new javax.swing.JButton();
        delete_btn = new javax.swing.JButton();

        setPreferredSize(new java.awt.Dimension(640, 520));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("Nummer:");

        number_Txt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        number_Txt.setToolTipText("Geef hier het nummer van de leverancier op.\\n Alleen cijfers zijn toegestaan!");
        number_Txt.setInputVerifier(new NumberVerifier(999));
        number_Txt.setMargin(new java.awt.Insets(2, 5, 2, 2));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Naam:");

        name_txt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        name_txt.setInputVerifier(new LengthVerifier(45));
        name_txt.setMargin(new java.awt.Insets(2, 5, 2, 2));

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel3.setText("Straat:");

        street_txt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        street_txt.setInputVerifier(new LengthVerifier(45));
        street_txt.setMargin(new java.awt.Insets(2, 5, 2, 2));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setText("Nr:");

        streetNumber_txt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        streetNumber_txt.setInputVerifier(new LengthVerifier(10));
        streetNumber_txt.setMargin(new java.awt.Insets(2, 5, 2, 2));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setText("Bus:");

        bus_txt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        bus_txt.setInputVerifier(new LengthVerifier(10));
        bus_txt.setMargin(new java.awt.Insets(2, 5, 2, 2));

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel6.setText("Land:");

        country_cmb.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        country_cmb.setModel(new CountryComboBoxModel());
        country_cmb.setSelectedIndex(0);
        country_cmb.setEnabled(false);

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel7.setText("Postcode:");

        postalCode_txt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        postalCode_txt.setInputVerifier(new LengthVerifier(10));
        postalCode_txt.setMargin(new java.awt.Insets(2, 5, 2, 2));

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("Plaats:");

        location_txt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        location_txt.setInputVerifier(new LengthVerifier(45));
        location_txt.setMargin(new java.awt.Insets(2, 5, 2, 2));

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel9.setText("Taalcode:");

        language_cmb.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        language_cmb.setModel(new LanguageComboboxModel());
        language_cmb.setSelectedIndex(0);
        language_cmb.setEnabled(false);

        telecom_tbl.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        telecom_tbl.setModel(telecomTableModel);
        telecom_tbl.setDropMode(javax.swing.DropMode.INSERT);
        telecom_tbl.setFillsViewportHeight(true);
        telecom_tbl.setRowHeight(25);
        telecom_tbl.setRowMargin(5);
        jScrollPane1.setViewportView(telecom_tbl);

        jTextArea1.setColumns(20);
        jTextArea1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextArea1.setRows(5);
        jScrollPane2.setViewportView(jTextArea1);

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel10.setText("Opmerking:");

        save_btn.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        save_btn.setMnemonic(KeyEvent.VK_S);
        save_btn.setText("Opslaan");
        save_btn.setEnabled(false);
        save_btn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveAction(evt);
            }
        });

        addTelecom.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        addTelecom.setMnemonic(KeyEvent.VK_T);
        addTelecom.setText("Telecom toevoegen");
        addTelecom.setEnabled(false);
        addTelecom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addTelecom(evt);
            }
        });

        delete_btn.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        delete_btn.setText("Verwijderen");
        delete_btn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteSupplier(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(save_btn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(delete_btn))
                    .addComponent(jScrollPane2)
                    .addComponent(number_Txt, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(name_txt)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(country_cmb, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(postalCode_txt))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(street_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel4)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(streetNumber_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(bus_txt, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(location_txt))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(language_cmb, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(addTelecom))
                    .addComponent(jScrollPane1))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(29, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(number_Txt, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(name_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(street_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(streetNumber_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(bus_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(country_cmb, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(postalCode_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(location_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(language_cmb, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(addTelecom))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(save_btn)
                    .addComponent(delete_btn))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void SaveAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveAction
        if (verify()) {
            if (newSupplier) {
                System.out.println(street_txt.getText() + ", " + streetNumber_txt.getText() + ", " + postalCode_txt.getText() + ", " + bus_txt.getText() + ", " + location_txt.getText() + ", " + true + ", " + countryComboBoxModel.getId(country_cmb.getSelectedIndex()) + ", " + 1l);
                Long addressId = EJBModel.getAddressBean().createAddress(street_txt.getText(), streetNumber_txt.getText(), postalCode_txt.getText(), bus_txt.getText(), location_txt.getText(), true, countryComboBoxModel.getId(country_cmb.getSelectedIndex()), 1l);
                Integer supplierId = EJBModel.getSupplierBean().createSupplier(name_txt.getText(), Integer.parseInt(number_Txt.getText()), null, languageComboBoxModel.getId(language_cmb.getSelectedIndex()), addressId);
                telecomTableModel.saveTelecom(supplierId);
                model.setStatus("Leverancier " + number_Txt.getText() + " is opgeslaan");

            } else {
                EJBModel.getAddressBean().editAddress(currentAddress.getId(), street_txt.getText(), streetNumber_txt.getText(), postalCode_txt.getText(), bus_txt.getText(), location_txt.getText(), true, countryComboBoxModel.getId(country_cmb.getSelectedIndex()), 1l);
                EJBModel.getSupplierBean().editSupplier(currentSupplier.getId(), name_txt.getText(), Integer.parseInt(number_Txt.getText()), null, languageComboBoxModel.getId(language_cmb.getSelectedIndex()), currentAddress.getId());
                telecomTableModel.editTelecom();
                telecomTableModel.saveTelecom(currentSupplier.getId());
                model.setStatus("Leverancier " + number_Txt.getText() + " is aangepast");
            }
        }
    }//GEN-LAST:event_SaveAction

    private void addTelecom(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addTelecom
        telecomTableModel.addValue();
    }//GEN-LAST:event_addTelecom

    private void deleteSupplier(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSupplier
        telecomTableModel.deleteTelecom(currentSupplier.getTelecomCollection());
        EJBModel.getSupplierBean().removeSupplier(currentSupplier.getId());
        EJBModel.getAddressBean().removeAddress(currentAddress.getId());
        number_Txt.setText("");
        setTextFields("", "", "", "", "", "");
        country_cmb.setSelectedIndex(0);
        telecomTableModel.clearTelecom();
        model.setStatus("Leverancier " + currentSupplier.getNumber() + " is verwijderd");

    }//GEN-LAST:event_deleteSupplier
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addTelecom;
    private javax.swing.JTextField bus_txt;
    private javax.swing.JComboBox country_cmb;
    private javax.swing.JButton delete_btn;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JPopupMenu jPopupMenu2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JComboBox language_cmb;
    private javax.swing.JTextField location_txt;
    private javax.swing.JTextField name_txt;
    private javax.swing.JTextField number_Txt;
    private javax.swing.JTextField postalCode_txt;
    private javax.swing.JButton save_btn;
    private javax.swing.JTextField streetNumber_txt;
    private javax.swing.JTextField street_txt;
    private javax.swing.JTable telecom_tbl;
    // End of variables declaration//GEN-END:variables

    @Override
    public void focusGained(FocusEvent e) {
    }

    @Override
    public void focusLost(FocusEvent e) {
        if (e.getSource() == number_Txt && !number_Txt.getText().isEmpty()) {
            try {
                int number = Integer.parseInt(number_Txt.getText());
                save_btn.setEnabled(true);
                addTelecom.setEnabled(true);
                country_cmb.setEnabled(true);
                language_cmb.setEnabled(true);
                if (EJBModel.getSupplierBean().exists(number)) {
                    newSupplier = false;
                    currentSupplier = EJBModel.getSupplierBean().findByNumber(number);
                    currentAddress = EJBModel.getAddressBean().getAddressDetails(currentSupplier.getAddressId());
                    setTextFields(currentSupplier.getName(), currentAddress.getStreet(), currentAddress.getNumber(), currentAddress.getBus(), currentAddress.getLocation(), currentAddress.getPostalCode());
                    country_cmb.setSelectedIndex(countryComboBoxModel.getIndexOf(currentAddress.getCountryId()));
                    language_cmb.setSelectedIndex(languageComboBoxModel.getIndexOf(currentSupplier.getLanguageId()));
                    System.out.println("Laad telecom");
                    telecomTableModel.loadTelecom(currentSupplier.getTelecomCollection());
                    model.setStatus("Leverancier " + number_Txt.getText() + " is geladen");
                } else {
                    newSupplier = true;
                    setTextFields("", "", "", "", "", "");
                    country_cmb.setSelectedIndex(0);
                    telecomTableModel.clearTelecom();
                    model.setStatus("Leverancier " + number_Txt.getText() + " is nieuw");

                }
            } catch (Exception ex) {
                save_btn.setEnabled(false);
                addTelecom.setEnabled(false);
                country_cmb.setEnabled(false);
                language_cmb.setEnabled(false);
            }
        }
    }

    private void setTextFields(String name, String street, String number, String bus, String location, String postalCode) {
        name_txt.setText(name);
        street_txt.setText(street);
        streetNumber_txt.setText(number);
        bus_txt.setText(bus);
        location_txt.setText(location);
        postalCode_txt.setText(postalCode);
    }

    public boolean verify() {
        ArrayList<String> emptyFields = new ArrayList<String>();
        if (number_Txt.getText().trim().length() <= 0) {
            emptyFields.add("Fabrikantnummer");
        }
        if (name_txt.getText().trim().length() <= 0) {
            emptyFields.add("Naam");
        }
        if (street_txt.getText().trim().length() <= 0) {
            emptyFields.add("Straat");
        }
        if (streetNumber_txt.getText().trim().length() <= 0) {
            emptyFields.add("Straatnummer");
        }
        if (postalCode_txt.getText().trim().length() <= 0) {
            emptyFields.add("Postcode");
        }
        if (location_txt.getText().trim().length() <= 0) {
            emptyFields.add("Plaats");
        }
        if (emptyFields.size() > 0) {
            String message = "Gelieve de volgende velden in te vullen:";
            
            for (String s : emptyFields) {
                message += "\n    - " + s;

            }
            JTextArea text = new JTextArea(message);
            text.setFont(new Font("Tahoma", 0, 14));
            text.setBackground(new Color(240,240,240));
            JOptionPane.showMessageDialog(this, text, "Gelieve alle velden in te vullen", JOptionPane.ERROR_MESSAGE);
            return false;
        }
        return true;
    }
}
